| Begin |
| Initialize particle swarm, including the settlement of the original position Xi and original speed Vi. |
| Repeat |
| Transfer the form of the parameters of LS-SVM, according to the binary form of the grains. |
| Compare the value of the fitness function of every grain f(xi) with its optimum value f(pbesti). |
| If |
| f(xi) < f(pbesti) |
| Make the value of the fitness function take place of the value of the fitness function before, and so it is with the grain. |
| Compare the value of the fitness function of every grain f(xi) with the global optimum value f(gbesti). |
| If |
| f(xi) < f(gbesti), |
| Make the value of the fitness function of that grain take place of the optimum value of the fitness function before, and so it is with the grain. |
| Update the speed and value of the grains according to the Equations (1) and (2), and build the new population Xi+1. Update the speed according to the rules: if vi > Vmax, vi = Vmax, if vi ≤ −Vmax, vi = −Vmax. |
| Update the inertia factor w. |
| Update the binary digit of the grains. |
| Check whether the requirement of ending is satisfied. The requirement is reaching the max iterations or the evaluation of estimate is less than the given accuracy. |
| Improve the iteration. Make T = T + 1. |
| Until |
| The requirement of ending is satisfied, end the selection for the best feature, and return the best character subset and classification accuracy. |